package cn.gjxblog.mq.mechanism.ack;

import cn.gjxblog.mq.utils.ConnectionUtils;
import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import java.util.HashMap;


/**
 * @author gjx
 * @version v1.0
 * @Description
 * @date 2019/7/4 11:48
 */
public class Producer {
    public static void main(String[] args) throws Exception {
        Connection connection = ConnectionUtils.getConnection();
        Channel channel = connection.createChannel();

        String exchangeName = "test_ack_exchange";
        String routingKey = "ack.save";

        for (int i = 0; i < 5; i++) {
            String msg = "Hello RabbitMQ!"+i;
            channel.basicPublish(exchangeName,routingKey,null,msg.getBytes());
        }

        //关闭相关连接
        channel.close();
        connection.close();
    }
}
